<?php
/*
*首页接口类
*/
class homeAppClass extends app{
	/*工资曲线~返回数据*/
	public function wages(){
		//判断
		if(empty($this->post['startMoon'])){
			$json['warn'] = "请填写开始月份";
		}elseif(empty($this->post['endMoon'])){
			$json['warn'] = "请填写结束月份";
		}elseif(strtotime($this->post['startMoon']) > strtotime($this->post['endMoon'])){
			$json['warn'] = "开始月份不能大于结束月份";
		}elseif(strtotime($this->post['endMoon']."-01 00:00:00") > time()){
			$json['warn'] = "结束月份不得大于当前月份";
		}else{
			//分析数据
			$json['list'] = $json['income'] = array();
			$moonArray = $this->moon(array("start" => $this->post['startMoon'],"end" => $this->post['endMoon']));
			foreach($moonArray as $moon){
				$json['list'][] = $moon['start'];
				$moonStart = $moon['end']."-1 00:00:00";//当月工资下月结算。
				$moonEnd = date("Y-m",strtotime($moonStart)+3600*24*40)."-01 00:00:00";//月初加40天，肯定是次月
				$json['income'][] = find(array(
					"table" => "record",
					"sum" => "money",
					"where" => "type = '员工结算账户' and typeid = '".$this->control['stid']."' and direction = '收入' and time >= '$moonStart' and time <= '$moonEnd'",
				));
			}
			//提示
			$json['warn'] = "success";
		}
		//基本工资
		$json['basePay'] = $this->controlJob['basePay'];
		//岗位津贴
		$json['subsidy'] = $this->controlJob['subsidy'];
		//会计账户
		$json['money'] = $this->control['money'];
		//结算账户
		$json['lastMoney'] = $this->control['lastMoney'];
		//待办事项
		$date = date("Y-m-d");
		$json['backlog'] = sqlNum("backlog"," stid = '".$this->control['stid']."' and workFlow = '待处理' and startDay <= '$date' ");
		//返回
		return $json;
	}
}